<template>
  <div>
    <el-single-select
      :dataObj="singleSelectData"
      :prop="singleSelectColumn"
      @confirm="confirm"
      :dialogVisible.sync="dialogVisible"
      :title="title"
    >
      <template slot="dialogTop">
        <div class="dialog-input">
          <span class="label">验收单编号：</span>
          <el-input
            placeholder="请输入验收单编号模糊查询"
            v-model.trim="formDate.acceptanceNumber"
            style="width: 260px"
            clearable
          ></el-input>
        </div>
        <div class="dialog-input">
          <span class="label"> 验收单名称：</span>
          <el-input
            placeholder="请输入验收单名称模糊查询"
            v-model.trim="formDate.acceptanceName"
            style="width: 260px"
            @blur="handleTrim('acceptanceName')"
            clearable
          ></el-input>
        </div>
        <div class="dialog-input">
          <span class="label"> 供应商：</span>
          <el-input
            placeholder="请输入供应商模糊查询"
            v-model.trim="formDate.supplier"
            style="width: 260px"
            clearable
          ></el-input>
        </div>
        <div class="dialog-input">
          <span class="label"> 填报单位：</span>
          <el-input
            placeholder="请输入填报单位模糊查询"
            v-model.trim="formDate.reportInOrgName"
            style="width: 260px"
            clearable
          ></el-input>
        </div>
        <div class="dialog-input">
          <span class="label"> 验收人：</span>
          <el-input
            placeholder="请输入验收人模糊查询"
            v-model.trim="formDate.acceptor"
            style="width: 260px"
            clearable
          ></el-input>
        </div>
        <div style="width: 100%; display: flex; justify-content: center">
          <el-button
            size="mini"
            type="primary-font-mini"
            @click="singleSelectSearch"
            >搜索
          </el-button>
          <el-button size="mini" type="default-mini" @click="handleReset"
            >重置
          </el-button>
        </div>
      </template>
    </el-single-select>
  </div>
</template>
<script>
import { listAcceptanceCert } from "../api/bowOut";
export default {
  name: "contactSupplier",
  data() {
    return {
      title: "选择验收单编号",
      // 招标结果关联弹窗相关变量 start
      formDate: {
        acceptanceNumber: "", //验收单编号
        acceptanceName: "", //验收单名称
        supplier: "", //供应商
        reportInOrgName: "", //填报单位
        acceptor: "" //验收人
      },
      singleSelectData: [],
      singleSelectColumn: [
        { prop: "acceptanceNumber", label: "验收单编号", width: "150" },
        { prop: "acceptanceName", label: "验收单名称", width: "300" },
        { prop: "supplier", label: "供应商", width: "200" },
        { prop: "acceptor", label: "验收人", width: "150" },
        { prop: "reportInOrgName", label: "填报单位", width: "200" },
        { prop: "acceptanceCurrentNumber", label: "验收数量", width: "80" }
        // { prop: "arrivalPlace", label: "到货地点", width: "200" }
      ],
      dialogVisible: false
    };
  },
  props: {
    partBdata: {
      type: Array,
      default() {
        return [];
      }
    },
    partyAId: {
      type: Number
    },
    reportInOrgId: {
      type: Number
    }
  },
  watch: {
    partBdata(data) {
      this.singleSelectData = data;
    },
    partyAId(data) {
      this.formDate.orgid = data;
    }
  },
  methods: {
    //数据
    getSupplierData() {
      alert();
      listAcceptanceCert({
        reportInOrgId: this.reportInOrgId,
        moduleType: "bowOut",
        businessType: "1"
      }).then(res => {
        this.singleSelectData = res.data.data;
      });
    },
    confirm(val) {
      this.$emit("partyBName", val);
      this.$bus.$emit("partyBValue", val);
    },
    //搜索
    singleSelectSearch() {
      listAcceptanceCert({
        acceptanceNumber: this.formDate.acceptanceNumber, //验收单编号
        acceptanceName: this.formDate.acceptanceName, //验收单名称
        supplier: this.formDate.supplier, //供应商
        acceptor: this.formDate.acceptor, //验收人
        reportInOrgId: this.reportInOrgId,
        moduleType: "bowOut",
        businessType: "1"
      }).then(res => {
        this.singleSelectData = res.data.data;
      });
    },
    //重置
    handleReset() {
      this.formDate = {
        acceptanceNumber: "", //验收单编号
        acceptanceName: "", //验收单名称
        supplier: "", //供应商
        reportInOrgName: "" //填报单位
      };
    },
    handleTrim(key) {
      this.$set(
        this.formDate,
        key,
        this.formDate[key].replace(/(^\s*)|(\s*)$/g, "")
      );
    }
  },
  mounted() {
    this.getSupplierData();
    console.log(this.reportInOrgId);
  }
};
</script>
<style lang="scss" scoped>
/deep/.el-single-select
  .el-dialog__wrapper
  .el-dialog
  .el-dialog__body
  .el-dialog-box
  .dialog-top {
  justify-content: space-between;
}
/deep/ .el-table__body-wrapper {
  max-height: 230px !important;
}
/deep/.label {
  display: inline-block;
  width: 130px !important;
  text-align: right;
}
/deep/ .el-dialog__footer {
  border-top: none;
}
/deep/ .el-dialog__footer .dialog-footer #ccui-paging {
  display: none !important;
}
</style>
